#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.59])
AC_INIT([Laggard], [0.4], [http://code.google.com/p/laggard/])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])


# Checks for programs.
AC_PROG_CC_C99
AM_PROG_CC_C_O

# Checks for libraries.

# Checks for header files.
AC_HEADER_ASSERT
AC_HEADER_TIME
AC_CHECK_HEADERS([ctype.h fcntl.h inttypes.h stdint.h])
AC_CHECK_HEADERS([sys/select.h sys/stat.h unistd.h setjmp.h])

# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_C_CONST
AC_TYPE_INT16_T
AC_TYPE_INT64_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T

# Checks for library functions.
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([gethostname gettimeofday isatty memset strchr strtol setjmp])


# Configure options: --enable-debug[=no].
AC_ARG_ENABLE([debug],
  [AS_HELP_STRING([--enable-debug],
    [enable debug code (default is no)])],
  [debug="$withval"], [debug=no])

# Configure DEBUG options, if requested.
if test "x$debug" = xno; then   
   AC_DEFINE([NDEBUG], [1], [Disable assertions])
else
   AC_DEFINE([LAGGARD_DEBUG], [1], [Define to enable debug code])
fi

# Configure options: --enable-stats[=no].
AC_ARG_ENABLE([stats],
  [AS_HELP_STRING([--enable-stats],
    [enable the collection of statistics (default is no)])],
  [stats="$withval"], [stats=no])

# Configure STATS options, if requested.
if test "x$stats" != xno; then   
   AC_DEFINE([LAGGARD_STATS], [1], [Define to enable statistics])
fi


# SVN revision
SVNREV=`svnversion $srcdir | sed 's/:.*//'`
which svnversion > /dev/null; \
if [[ $? -ne 0 ]] || [[ "x$SVNREV" = "xexported" ]]
  then SVNREV=`cat $srcdir/SVNREV`
  else echo -n $SVNREV > $srcdir/SVNREV
fi
AC_SUBST(SVNREV)


AC_CONFIG_FILES([Makefile
		src/Makefile])
AC_OUTPUT
